* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========== 全局主题变量 ========== */
:root {
    /* 浅色主题（默认） */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #d0d0d0;
    --border-color-light: #e0e0e0;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
}

/* 深色主题 */
:root.dark-theme,
body.dark-theme {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --text-primary: #d4d4d4;
    --text-secondary: #858585;
    --border-color: #3e3e42;
    --border-color-light: #2d2d30;
    --sidebar-bg: #1a1a1a;
    --sidebar-hover: #2d2d2d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar */
.sidebar {
    width: 150px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--sidebar-hover);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: white;
}

/* 主题切换按钮 */
.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-icon {
    display: block;
    line-height: 1;
}

.sidebar-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.sidebar-item:hover {
    background-color: var(--sidebar-hover);
}

.sidebar-item.active {
    background-color: #3498db;
    border-left-color: #2980b9;
}

.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* JSON Container */
.json-container {
    display: flex;
    height: 100%;
    gap: 0;
    overflow: hidden;
}

.json-left,
.json-right {
    flex: 1;
    width: 50%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    min-width: 0;
}

.json-left {
    border-right: 1px solid var(--border-color);
}

.json-header {
    padding: 15px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 56px;
}

.json-header h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin: 0;
}

.json-search {
    padding: 10px 20px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.json-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.json-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.json-input {
    width: 100%;
    height: 100%;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    resize: none;
    outline: none;
    padding: 20px;
    overflow: auto;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.json-tree {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.8;
    padding: 20px;
    height: 100%;
    overflow: auto;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.json-line {
    position: relative;
    padding-left: 20px;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.json-line.has-children {
    padding-left: 40px;
}

.collapse-btn {
    position: absolute;
    left: 0;
    width: 20px;
    height: 20px;
    border: 1px solid var(--text-secondary);
    background: var(--bg-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: 2px;
    user-select: none;
}

.collapse-btn:hover {
    background-color: var(--bg-tertiary);
}

.json-children {
    position: relative;
    margin-left: 20px;
    border-left: 1px dashed var(--border-color);
    padding-left: 20px;
}

.json-children.collapsed {
    display: none;
}

.json-ellipsis {
    color: var(--text-secondary);
    font-style: italic;
}

.json-key {
    color: #a626a4;
    cursor: pointer;
}

.json-key:hover {
    text-decoration: underline;
}

.json-key-path {
    margin-left: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.json-key-path span {
    color: var(--text-secondary);
}

.json-key-path button {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    background-color: transparent;
    color: #3498db;
    border: 1px solid #3498db;
}

.json-key-path button:hover {
    background-color: #3498db;
    color: white;
}

.json-key-path button.copied {
    background-color: #27ae60;
    color: white;
    border-color: #27ae60;
}

.json-string {
    color: #50a14f;
    word-break: break-word;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.json-number {
    color: #4078f2;
}

.json-boolean {
    color: #e45649;
}

.json-null {
    color: #808080;
}

.json-bracket {
    color: #000;
    font-weight: bold;
}

/* Buttons */
button {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

button:hover {
    background-color: #2980b9;
}

button.secondary {
    background-color: #95a5a6;
}

button.secondary:hover {
    background-color: #7f8c8d;
}

/* Messages */
.message {
    padding: 10px 20px;
    background-color: #fadbd8;
    color: #e74c3c;
    border-left: 4px solid #e74c3c;
    display: none;
}

.message.show {
    display: block;
}

.message.success {
    background-color: #d5f4e6;
    color: #27ae60;
    border-left-color: #27ae60;
}

.highlight {
    background-color: #ffeb3b !important;
}

/* Simple Panel */
.simple-panel {
    padding: 30px;
    background-color: var(--bg-primary);
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex: 1;
    overflow: auto;
}

.simple-panel h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 24px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

textarea,
input[type="text"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

textarea {
    min-height: 200px;
    resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #3498db;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Text Comparator */
.line-numbers {
    width: 40px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 20px 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    text-align: right;
    color: #999;
    user-select: none;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.line-numbers::-webkit-scrollbar {
    width: 0;
    display: none;
}

.line-numbers .line-num {
    display: block;
    line-height: 1.6;
}

.line-numbers .line-num.diff-line {
    background-color: #fadbd8;
    color: #e74c3c;
    font-weight: bold;
}

.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px;
    margin: 0;
    border: 2px solid transparent;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    pointer-events: none;
    color: transparent;
    z-index: 1;
    box-sizing: border-box;
}

.highlight-layer>div {
    transition: none;
}

.compare-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: auto;
    background: transparent;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    outline: none;
    resize: none;
    z-index: 2;
    box-sizing: border-box;
}

.diff-char {
    background-color: #fadbd8;
    color: #e74c3c;
}